package com.qo.qsdk.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.qo.qsdk.QSDK;
import com.qo.qsdk.ui.base.ExitView;
import com.qo.qsdk.ui.base.TipView;

public class TipActivity extends BaseActivity {

    private TipView mTipView;
    public static final String TIP_EXTRA = "TIP_EXTRA";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mTipView = new TipView(this, mQSDKListener);
        mTipView.show(this, getIntent().getStringExtra(TIP_EXTRA));
    }

    public static void tip(Activity activity, String msg) {
        Intent intent = new Intent(activity, TipActivity.class);
        intent.putExtra(TIP_EXTRA, msg);
        activity.startActivity(intent);
    }

    QSDKListener mQSDKListener = new QSDKListener(){

        @Override
        public void onTipClose() {
            finish();
        }
    };


    @Override
    public void onBackPressed() {
        if (mQSDKListener != null) mQSDKListener.onTipClose();
        super.onBackPressed();
    }
}
